package com.gupaoedu.design.prototype.simple;

/**
 * <p></p>
 *
 * @author Andy
 * @date 2018/3/9.
 */
public class SimplePrototypeTest {

    public static void main(String[] args) {
        SubPrototype s1 = new SubPrototype();
        s1.setName("Tom");

        Prototype p1 = new Prototype();
        p1.setName("Andy");
        p1.setTarget(s1);

        try {
            Prototype p2 = (Prototype) p1.clone();
            SubPrototype s2 = p2.getTarget();
            s2.setName("Mic");

            System.out.println("复制前的s" + s1);
            System.out.println("复制后的s" + s2);
            System.out.println(s1 == s2);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}
